package com.global;

import com.utils.R;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

//@RestControllerAdvice  //全局异常捕获
public class GlobalExceptionHandler {
    //    全部异常捕获
    @ResponseStatus(HttpStatus.SERVICE_UNAVAILABLE ) //500
    @ExceptionHandler(value = IOException.class)
    public R<String> handler(Exception e) {
        return R.error("传输异常，请联系管理员");
    }
}
